package svl;

import java.io.IOException;
import java.util.*;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dominio.ItemSolicitud;

import app.CPR;
import app.Odv;
import app.dto.*;

/**
 * Servlet implementation class listaPrecios
 */
@WebServlet("/listaPrecios")
public class listaPrecios extends HttpServlet {
	private static final long serialVersionUID = 1L;

	private static List<DetalleItemDto> items = new ArrayList<DetalleItemDto>();
	/**
	 * Default constructor.
	 */
	public listaPrecios() {
		// TODO Auto-generated constructor stub
	}
	

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		String sufijo = request.getParameter("codigo");
		String serie = request.getParameter("serie");
		String marca = request.getParameter("marca");
		String carac = request.getParameter("caracteristicas");
		String origen = request.getParameter("origen");
		boolean todos = Boolean.parseBoolean(request.getParameter("todos"));
		
		List<DetalleItemDto> items = CPR.getCPR().obtenerListaMejoresPrecios(marca, carac, origen, sufijo, serie, todos);
		
		request.setAttribute("items",items);
		
		String dire = "/WEB-INF/out/listaPrecios.jsp";
		RequestDispatcher dispatcher = request.getRequestDispatcher(dire);
	    dispatcher.forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		
		
		
		
	}
}
